package com.yc.cloud.admin.dto.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 获取媒体列表响应对象
 * 用于 getMediaList 接口
 * 
 * @author kinggu
 * @since 2025-01-XX
 */
@Data
@ApiModel(value = "MediaListResponse", description = "获取媒体列表响应")
public class MediaListResponse {

    @ApiModelProperty("执行结果代码，0表示成功")
    private Integer code;

    @ApiModelProperty("响应消息")
    private String msg;

    @ApiModelProperty("媒体流列表数据")
    private List<MediaInfo> data;

    /**
     * 判断是否成功
     */
    public boolean isSuccess() {
        return code != null && code == 0;
    }

    /**
     * 媒体流信息
     */
    @Data
    @ApiModel(value = "MediaInfo", description = "媒体流信息")
    public static class MediaInfo {
        
        @ApiModelProperty("应用名")
        private String app;

        @ApiModelProperty("流ID")
        private String stream;

        @ApiModelProperty("协议")
        private String schema;

        @ApiModelProperty("虚拟主机名")
        private String vhost;

        @ApiModelProperty("产生源类型")
        @JsonProperty("originType")
        private Integer originType;

        @ApiModelProperty("产生源类型字符串")
        @JsonProperty("originTypeStr")
        private String originTypeStr;

        @ApiModelProperty("产生源的URL")
        @JsonProperty("originUrl")
        private String originUrl;

        @ApiModelProperty("GMT unix系统时间戳，单位秒")
        @JsonProperty("createStamp")
        private Long createStamp;

        @ApiModelProperty("存活时间，单位秒")
        @JsonProperty("aliveSecond")
        private Integer aliveSecond;

        @ApiModelProperty("数据产生速度，单位byte/s")
        @JsonProperty("bytesSpeed")
        private Long bytesSpeed;

        @ApiModelProperty("本协议观看人数")
        @JsonProperty("readerCount")
        private Integer readerCount;

        @ApiModelProperty("观看总人数")
        @JsonProperty("totalReaderCount")
        private Integer totalReaderCount;

        @ApiModelProperty("音视频轨道")
        private List<TrackInfo> tracks;

        @ApiModelProperty("客户端和服务器网络信息")
        @JsonProperty("originSock")
        private OriginSock originSock;
    }

    /**
     * 音视频轨道信息
     */
    @Data
    @ApiModel(value = "TrackInfo", description = "音视频轨道信息")
    public static class TrackInfo {
        @ApiModelProperty("音频通道数")
        private Integer channels;

        @ApiModelProperty("编码ID")
        @JsonProperty("codec_id")
        private Integer codecId;

        @ApiModelProperty("编码类型名称")
        @JsonProperty("codec_id_name")
        private String codecIdName;

        @ApiModelProperty("编码类型：Video = 0, Audio = 1")
        @JsonProperty("codec_type")
        private Integer codecType;

        @ApiModelProperty("轨道是否准备就绪")
        private Boolean ready;

        @ApiModelProperty("累计接收帧数")
        private Long frames;

        @ApiModelProperty("音频采样位数")
        @JsonProperty("sample_bit")
        private Integer sampleBit;

        @ApiModelProperty("音频采样率")
        @JsonProperty("sample_rate")
        private Integer sampleRate;

        @ApiModelProperty("视频fps")
        private Integer fps;

        @ApiModelProperty("gop间隔时间，单位毫秒")
        @JsonProperty("gop_interval_ms")
        private Integer gopIntervalMs;

        @ApiModelProperty("gop大小，单位帧数")
        @JsonProperty("gop_size")
        private Integer gopSize;

        @ApiModelProperty("累计接收关键帧数")
        @JsonProperty("key_frames")
        private Long keyFrames;

        @ApiModelProperty("视频高度")
        private Integer height;

        @ApiModelProperty("视频宽度")
        private Integer width;
    }

    /**
     * 客户端和服务器网络信息
     */
    @Data
    @ApiModel(value = "OriginSock", description = "网络连接信息")
    public static class OriginSock {
        @ApiModelProperty("标识符")
        private String identifier;

        @ApiModelProperty("本地IP")
        @JsonProperty("local_ip")
        private String localIp;

        @ApiModelProperty("本地端口")
        @JsonProperty("local_port")
        private Integer localPort;

        @ApiModelProperty("对端IP")
        @JsonProperty("peer_ip")
        private String peerIp;

        @ApiModelProperty("对端端口")
        @JsonProperty("peer_port")
        private Integer peerPort;
    }
}
